/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package services.impl;

import domain.Hotelroom;
import domain.OrderRoom;
import domain.Products;
import domain.Users;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import services.interfaces.IOrderServices;

/**
 *
 * @author amega
 */
@Stateless
@LocalBean
public class OrderRoomServices extends GenericServiceImpl<OrderRoom> implements IOrderServices {
    
    
    @PersistenceContext(unitName="RGHPU")
    private EntityManager em;
    
    public OrderRoomServices(){
        super(OrderRoom.class);
    }
    
    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
    
    public List<OrderRoom> getRoomOrdersDate(Hotelroom room, Users user) {
        
        Query q = em.createQuery("SELECT p FROM OrderRoom p,Orders o WHERE p.idRoomNumber =:room and o.idUser=:user").setParameter("room", room).setParameter("user", user);
        return (Vector<OrderRoom>)q.getResultList();
    }
}
